﻿Imports System.Data.SqlClient

Public Class clsConsecuencias
    Public Sub Insertar(ByVal CLAVE As String, ByVal MONTO As Double, ByVal MOTIVO As String, ByVal LEVANTO As String, ByVal AUTORIZO As String)
        Dim sql As String = "Insert Into CONSECUENCIAS " & _
                             "VALUES (" & _
                            "@FECHA," & _
                            "@CLAVE," & _
                            "@MONTO," & _
                            "@MOTIVO," & _
                            "@LEVANTO," & _
                            "@AUTORIZO," & _
                            "@COBRADO)"

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("FECHA", Now())
        Command.Parameters.AddWithValue("CLAVE", CLAVE)
        Command.Parameters.AddWithValue("MONTO", MONTO)
        Command.Parameters.AddWithValue("MOTIVO", MOTIVO)
        Command.Parameters.AddWithValue("LEVANTO", LEVANTO)
        Command.Parameters.AddWithValue("AUTORIZO", AUTORIZO)
        Command.Parameters.AddWithValue("COBRADO", -1)

        cnConn.Open()
        Dim RowsAffected As Integer
        Try
            RowsAffected = Command.ExecuteNonQuery
            If RowsAffected > 0 Then
                cnConn.Close()
            Else
                If cnConn.State = ConnectionState.Open Then
                    cnConn.Close()
                End If
            End If
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Aviso")
        End Try


    End Sub
End Class
